package www.lagou.dao;

import org.apache.commons.dbutils.QueryRunner;
import www.lagou.entity.Transaction;
import www.lagou.utils.DruidUtils;

import java.sql.SQLException;

public class TransactionDao {

    public int transactionInsert(Transaction transaction) throws SQLException {

        //1.创建QueryRunner对象 自动模式,传入数据库连接池
        QueryRunner qr = new QueryRunner(DruidUtils.getDataSource());


        //2.编写SQL
        String sql = "insert into transaction value (?,?,?,?,?)";

        //3.设置占位符参数
        Object[] param = {null,transaction.getCardid(),transaction.getTratype(),transaction.getTramoney(),transaction.getTradate()};

        //4.执行update, 不需要传入连接对象
        return  qr.update(sql,param);
    }
}
